﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
class bankaccount
{
    string username;
    string password;
    int money;
    public string getname()
    {
        return username;
    }
    public string getpassword()
    {
        return password;
    }
    public void setusername(string name)
    {
        username = name;
    }
    public void setpassword(string password)
    {
        this.password = password;
    }
    public void savemoney(int money)
    {
        if (money > 0)
        {
            this.money += money;
            Console.WriteLine("save money success");
        }
        else
        {
            Console.WriteLine("cannot be smaller than Zero");
        }
    }
    public void takemoney(int money)
    {
        if (money > 0)
        {
            if (money > this.money)
            {
                Console.WriteLine("more than money in account");
            }
            else
            {
                this.money -= money;
                Console.WriteLine("take money success");
            }
        }
        else
        {
            Console.WriteLine("cannot be smaller than Zero");
        }
    }
}
class Bank
{
    string name;
    List<bankaccount> users = new List<bankaccount> { };
    public Bank(string name)
    {
        this.name = name;
    }
    public Bank()
    {
        this.name = "";
    }
    public void adduser(bankaccount cc)
    {
        users.Add(cc);
    }
    public string returnpassword(string name)
    {
        bankaccount temp= users.Find(s => s.getname() == name);
        return temp.getpassword();
    }
    public void savemoney(string name,int money)
    {
        bankaccount temp = users.Find(s => s.getname() == name);
        temp.savemoney(money);
    }
    public void takemoney(string name,int money)
    {
        bankaccount temp = users.Find(s => s.getname() == name);
        temp.takemoney(money);
    }
}
class ATM
{
    int moneyInATM;
    public bool input(string name,string password,Bank bank)
    {
        string userpassword=bank.returnpassword(name);
        if (password == userpassword)
        {
            return true;
        }
        return false;
    }
    public void savemoney(string name,Bank bank,int money)
    {
        bank.savemoney(name, money);
        moneyInATM += money;
    }
    public void takemoney(string name, Bank bank, int money)
    {
        bank.takemoney(name, money);
        moneyInATM -= money;
    }
}
class creditaccount :bankaccount
{
    int credit;
    public void setcredit(int credit)
    {
        this.credit = credit;
    }
}
class Program
{
    static void Main(string[] args)
    {
        Bank testbank=new Bank("testingbank");
        bankaccount Andy = new bankaccount();
        Andy.setusername("Andy");
        Andy.setpassword("20050205");
        ATM testatm = new ATM();
        testbank.adduser(Andy);
        testatm.savemoney("Andy", testbank, 10000);
        testatm.takemoney("Andy", testbank, 5000);
    }
}
